package com.glsc.ngateway.common.base.repo.mysql.gateway.other;

import com.glsc.ngateway.common.base.domain.mysql.gateway.other.TradeSeatFees;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

@Repository
public interface TradeSeatFeesRepository extends JpaRepository<TradeSeatFees, Integer>, JpaSpecificationExecutor<TradeSeatFees> {


//    @Query(value = "select  b.q ,b.p ,m.trading_offer_year_amount ,m.none_trading_offer_year_amount,a.flow_speed_weight  from ( select MAX(t.data_date ) p,t.trade_seat_code q from t_am_trade_seat_fees t group by t.trade_seat_code ) b left join t_am_trade_seat_fees m" +
//            " on m.trade_seat_code =b.q and m.data_date =b.p left join t_am_trade_seat_flow_speed a on a.trade_seat_code =m.trade_seat_code " +
//            " where t.status=1 and m.trade_seat_market =:tradeSeatMarket and m.trade_seat_code =:tradeSeatCode and m.data_date >= :beginDate and m.data_date <= :endDate  order by b.p desc ", nativeQuery = true)
//    List<Map<String, Object>> listTradeSeatFeesDto(String tradeSeatMarket, String tradeSeatCode, LocalDate beginDate, LocalDate endDate);
//
//
//    @Query(value = "select  b.q ,b.p ,m.trading_offer_year_amount ,m.none_trading_offer_year_amount,a.flow_speed_weight  from ( select MAX(t.data_date ) p,t.trade_seat_code q from t_am_trade_seat_fees t group by t.trade_seat_code ) b left join t_am_trade_seat_fees m" +
//            " on m.trade_seat_code =b.q and m.data_date =b.p left join t_am_trade_seat_flow_speed a on a.trade_seat_code =m.trade_seat_code " +
//            " where t.status=1 and m.trade_seat_market =:tradeSeatMarket and m.data_date >= :beginDate and m.data_date <= :endDate  order by b.p desc", nativeQuery = true)
//    List<Map<String, Object>> listTradeSeatFeesDto(String tradeSeatMarket, LocalDate beginDate, LocalDate endDate);
//
//    /**
//     * 查找本次计费周期内最早的交易单元费用记录
//     * @param tradeSeatCode
//     * @return
//     */
//    @Query(value = "select *  from t_am_trade_seat_fees t  where  t.status=1 and t.trade_seat_code = :tradeSeatCode order by t.data_date asc LIMIT 1 ", nativeQuery = true)
//    TradeSeatFees findFirstFeeInfo(String tradeSeatCode);
//
//    /**
//     * 按照计费周期更新交易单元计费信息为已过期
//     * @param dateLine
//     * @return
//     */
//    @Query(value = "update t_am_trade_seat_fees t set t.status =0 where t.status =1 and t.trade_seat_market =:tradeSeatMarket and t.data_date < :dateLine ", nativeQuery = true)
//    @Modifying
//    @Transactional
//    int updateFeesByDateLine(String dateLine, String tradeSeatMarket);

}
